﻿@{
    ViewBag.Title = "EnterpriseFTPList";
    Layout = null;
}
@using Webdiyer.WebControls.Mvc
@model PagedList<ElingOA6_Admin_DSJCJ.Model.FTP_New>
           
@{
    string IsUpload = ViewData["IsUpload"].ToString();
    string IsAgency = ViewData["IsAgency"].ToString();
    }
<!DOCTYPE html>
@Html.Partial("LoadPanelPartial")
<html>


<head>

    <title>文件上传下载</title>
    @if (false)
    {
        <script src="../../../../Scripts/jquery-vsdoc.js" type="text/javascript"></script>
        <script src="../../../../Scripts/ASPxScriptIntelliSense.js" type="text/javascript"></script>
        <script src="../../../../Scripts/json2.js" type="text/javascript"></script>  
    }
    <link href="@Url.Content("~/Content/Dqypt.css", true)" rel="stylesheet" type="text/css" />

    <script src="@Url.Content("~/Scripts/jquery.min.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/FloatDiv.js", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Common/GetRootPath.ashx", true)" type="text/javascript"></script>

    <script src="@Url.Content("~/Scripts/json2.js", true)" type="text/javascript"></script>

    <script type="text/javascript" src="@Url.Content("~/Scripts/SWFUpload/js/swfupload.js", true)"></script>

    <script type="text/javascript" src="@Url.Content("~/Scripts/SWFUpload/js/EnterpriseFTP_handlers.js", true)"></script>

   
        
    <script type="text/javascript">
        $(function(){
            /*全选按钮*/
            $('#chkALL').change(function(){
                if($('#chkALL').is(':checked'))
                {
                    $(':checkbox[name=checkbox2]').each(function(){
                        $(this).attr('checked',true);
                    })
                }
                else
                {
                    $(':checkbox[name=checkbox2]').each(function(){
                        $(this).attr('checked',false);
                    })
                }
            });
    
        });


        /*文件上传*/
        var swfu;
        window.onload = function () {
            swfu = new SWFUpload({
            upload_url: '@ViewData["upload_url"]',
            file_size_limit: '@ViewData["file_size_limit"]',
            file_types: '@ViewData["file_types"]',
            file_types_description: '@ViewData["file_types"]',
            file_upload_limit: '@ViewData["file_upload_limit"]',
            file_upload_limit: "0",    // Zero means unlimited

            // Event Handler Settings - these functions as defined in Handlers.js
            //  The handlers are not part of SWFUpload but are part of my website and control how
            //  my website reacts to the SWFUpload events.
            file_queue_error_handler: fileQueueError,
            file_dialog_complete_handler: fileDialogComplete,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: uploadSuccess,
            upload_complete_handler: uploadComplete,

            // Button settings
            button_image_url: '@ViewData["button_image_url"]',   // Relative to the SWF file 
            button_placeholder_id: "spanButtonPlaceholder",
            button_width: 110,
            button_height: 30,
            button_text: '',
            button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 17.5px; }',
            button_text_top_padding: 0,
            button_text_left_padding: 0,

            // Flash Settings
            flash_url: rootPath + "/Scripts/SWFUpload/swf/swfupload.swf", // Relative to this file

            custom_settings: {
                upload_target: "divFileProgressContainer"
            },
            // Debug Settings
            debug: false
        });
    }

    /*删除*/
    function del()
    {
        var parentId=$('#hdParentId').val();
        var strIds="";
        $(':checkbox[name=checkbox2]:checked').each(function(){
            var strId=$(this).attr('id');
            var array= strId.split('_');
            strIds+=array[1]+",";
        });
        if(strIds=="")
        {
            alert('请选择需要删除的文件。');
        }
        else
        {
            if (confirm("是否确定删除?")) {
                lpModal.Show();
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/EnterpriseFTPFront/DelFile',
                    data: { strIds: strIds },
                    success: function (result) {
                        if (result == "success") {
                            alert("删除成功!");
                        } else if (result == "error") {
                            alert("删除失败!");
                        } else {
                            alert("删除参数错误!");
                        }
                        window.location.href=rootPath+"/Admin/EnterpriseFTPFront/EnterpriseFTPList?FId="+parentId;
                    }
                });
            }
        }

    }

    /*下载*/
    function download()
    {
        var idArray=new Array();
        $(':checkbox[name=checkbox2]:checked').each(function(){
            var strId=$(this).attr('id');
            var array= strId.split('_');
            idArray.push(array[1]);
        });
        if(idArray.length==0)
        {
            alert('请选择需要下载的文件。');
        }
        else if(idArray.length==1) {

            lpOperation.Show();
            //  window.location.href=rootPath+"/Admin/EnterpriseFTPFront/Download?ids="+idArray.join('');
              $("#popContent").attr("src",rootPath+"/Admin/EnterpriseFTPFront/Download?ids="+idArray.join(''));
           // lp.Show();
        }
        else {
            lpOperation.Show();
            $("#popContent").attr("src", rootPath + "/Admin/EnterpriseFTPFront/DownloadList?ids=" + idArray.join(','));
       
           // window.location.href=rootPath+"/Admin/EnterpriseFTPFront/DownloadList?ids="+idArray.join(',');
        }
    }
    function hidelp() {

        lpOperation.Hide();
    }
    /*移动*/
    function move()
    {
        var idArray=new Array();
        $(':checkbox[name=checkbox2]:checked').each(function(){
            var strId=$(this).attr('id');
            var array= strId.split('_');
            idArray.push(array[1]);
        });
        if(idArray.length==0)
        {
            alert('请选择需要移动的文件。');
        }
        else
        {
            var strIds=idArray.join(",");
            var parentId=$('#hdParentId').val();
            var obj = new Object();
//            obj.Value = $("#hdSelEnterpriseFTPKeys").val();
            obj.Value="";
            var returnValue = window.showModalDialog(rootPath + "/Admin/Dialog/EnterpriseFTPChooseTree", obj, "dialogWidth=350px;dialogHeight=500px");
            if (typeof (returnValue) != "undefined") {
                $("#hdSelEnterpriseFTPKeys").val(returnValue);
                var destIdHtml=$("#hdSelEnterpriseFTPKeys").val();
                var destIdList=JSON.parse(returnValue);
                var destId=destIdList[0].Value;
                lpModal.Show();
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/EnterpriseFTPFront/MoveFile',
                    data: { strIds: strIds,destIdHtml:destIdHtml },
                    success: function (result) {
                        var resultArray= result.split('|');
                        if (resultArray[0] == "ok") {
                            lpModal.Hide();
                            alert("移动成功!");
                            parent.refreshLevelNode(destId);
                        }
                        else if (resultArray[0] == "notend"){
                            lpModal.Hide();
                            alert("目标不是末级节点，不能进行移动操作!");
                        } else if (resultArray[0] == "same"){
                            lpModal.Hide();
                            alert("目标文件夹中存在相同文件名的文件，不能再进行移动操作!");
                        } else if (resultArray[0] == "error") {
                            lpModal.Hide();
                            alert(resultArray[1]);
                        } else {
                            lpModal.Hide();
                            alert("参数错误!");
                        }
                        
                    }
                });

            }
        }
    }

    /*复制*/
    function copy()
    {
        var idArray=new Array();
        $(':checkbox[name=checkbox2]:checked').each(function(){
            var strId=$(this).attr('id');
            var array= strId.split('_');
            idArray.push(array[1]);
        });
        if(idArray.length==0)
        {
            alert('请选择需要复制的文件。');
        }
        else
        {
            var strIds=idArray.join(",");
            var parentId=$('#hdParentId').val();
            var obj = new Object();
//            obj.Value = $("#hdSelEnterpriseFTPKeys").val();
            obj.Value="";
            var returnValue = window.showModalDialog(rootPath + "/Admin/Dialog/EnterpriseFTPChooseTree", obj, "dialogWidth=350px;dialogHeight=500px");
            if (typeof (returnValue) != "undefined") {
                $("#hdSelEnterpriseFTPKeys").val(returnValue);
                var destIdHtml=$("#hdSelEnterpriseFTPKeys").val();
                var destIdList=JSON.parse(returnValue);
                var destId=destIdList[0].Value;
                lpModal.Show();
                $.ajax({
                    type: 'POST',
                    url: rootPath + '/Admin/EnterpriseFTPFront/CopyFile',
                    data: { strIds: strIds,destIdHtml:destIdHtml },
                    success: function (result) {
                        var resultArray= result.split('|');
                        if (resultArray[0] == "ok") {
                            lpModal.Hide();
                            alert("复制成功!");
                            parent.refreshLevelNode(destId);
                        }
                        else if (resultArray[0] == "notend") {
                            lpModal.Hide();
                            alert("目标不是末级节点，不能进行复制操作!");
                        } else if (resultArray[0] == "same") {
                            lpModal.Hide();
                            alert("目标文件夹中存在相同文件名的文件，不能再进行复制操作!");
                        } else if (resultArray[0] == "error") {
                            lpModal.Hide();
                            alert(resultArray[1]);
                        } else {
                            lpModal.Hide();
                            alert("参数错误!");
                        }
                       
                    }
                });

            }
        }
    }

    function rename()
    {
        var parentId=$('#hdParentId').val();
        var idArray=new Array();
        $(':checkbox[name=checkbox2]:checked').each(function(){
            var strId=$(this).attr('id');
            var array= strId.split('_');
            idArray.push(array[1]);
        });
        if(idArray.length==0)
        {
            alert('请选择需要重命名的文件。');
        }
        else if(idArray.length>1)
        {
            alert('请只选择一个需要重命名的文件。');
        }
        else
        {
            var obj = new Object();
//            obj.Value = $("#hdSelEnterpriseFTPKeys").val();
            obj.Value="";
            var strIds=idArray.join(",");
            var dt = new Date();
            var returnValue = window.showModalDialog(rootPath + "/Admin/EnterpriseFTPFront/EnterpriseRename?FId=" + strIds + "&s=" + dt.toTimeString(), obj, "dialogWidth=350px;dialogHeight=200px");

            if (typeof (returnValue) != "undefined") {
                var resultArray= returnValue.split('|');
                        if (resultArray[0] == "ok") {
                            alert("重命名成功!");
                            window.location.href=rootPath+"/Admin/EnterpriseFTPFront/EnterpriseFTPList?FId="+parentId;
                        }else if (resultArray[0] == "same"){
                            alert("存在相同文件名的文件，不能重命名!");
                        } else if (resultArray[0] == "error") {
                            alert(resultArray[1]);
                        } else {
                            alert("参数错误!");
                        }
                    
            }
        }
    }

    function iframeAutoFit() {
        var ex;
        try {
            if (window != parent) {
                var a = parent.document.getElementsByTagName("IFRAME");
                for (var i = 0; i < a.length; i++) {
                    if (a[i].contentWindow == window) {
                        var h1 = 0, h2 = 0;
                        if (document.documentElement && document.documentElement.scrollHeight) {
                            h1 = document.documentElement.scrollHeight;
                        }
                        if (document.body) h2 = document.body.scrollHeight;
                        var h = Math.max(h1, h2);
                        if (window.ActiveXObject) { h += 4; }
                        else { h += 4; }
                        a[i].style.height = h + "px";
                        window.removeEventListener('resize', iframeAutoFit, false); //兼容谷歌浏览器时要去掉RISZE监听
                    }
                }
            }
        }
        catch (ex) { }
    }
    
    

      </script>
    


  </head>

  




<body onload="">
<table width="100%" height="100%" border="0" align="center" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <div class="scxz_content">
                <div class="scxz_buttonnav">
                <!--如果上传，派出机构能上传下载；市局不能上传、可以管理删除下载-->
                <!--如果下载，派出机构不能上传，可以下载；市局能上传管理下载-->

                <!---新需求,上传属性文件夹所有部门(包括市局(虚拟部门))能修改下载当前部门文件,下载属性文件夹只有全局权限才能上传,其他员工只能下载>
                    @{
                        if ((bool)ViewData["isall"])
                        {
                                   <!--上传按钮 id="spanButtonPlaceholder"-->
                               
                            if ((bool)ViewData["isbottom"])
                            {
                         <span class="icon_btn1" >
                                    <span id="spanButtonPlaceholder"></span>
                                </span>
                            }
                            else
                            { 
                             <!--上传按钮 id="spanButtonPlaceholder"-->
                                <span class="icon_btn1" style="display:none;">
                                    <span id="spanButtonPlaceholder"></span>
                                </span>
                            }
                            if ((bool)ViewData["isbottom"])
                            {   
                                <a href="#" onclick="del()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz04.gif")"></a>
                            
                            }
                            <a href="#" onclick="download()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz05.gif")"></a>
                            if ((bool)ViewData["isbottom"])
                            {    
                            <a href="#" onclick="move()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz06.gif")"></a>
                                <a href="#" onclick="copy()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz07.gif")"></a>
                                <a href="#" onclick="rename()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz08.gif")"></a>
                              
                            }
                        }
                        else
                        {
                            if (IsUpload == "Y")
                            {
                                if ((bool)ViewData["isbottom"])
                                {
                                 <!--上传按钮 id="spanButtonPlaceholder"-->
                                 <span class="icon_btn1" >
                                    <span id="spanButtonPlaceholder"></span>
                                </span>
                                }
                                else
                                { 
                             <!--上传按钮 id="spanButtonPlaceholder"-->
                                <span class="icon_btn1" style="display:none;">
                                    <span id="spanButtonPlaceholder"></span>
                                </span>
                                }
                                if ((bool)ViewData["isbottom"] & (bool)ViewData["isall"])
                                {   
                                <a href="#" onclick="del()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz04.gif")"></a>
                                }
                        <a href="#" onclick="download()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz05.gif")"></a>
                                if ((bool)ViewData["isbottom"] & (bool)ViewData["isall"])
                                {      
                          <a href="#" onclick="move()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz06.gif")"></a>
                                <a href="#" onclick="copy()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz07.gif")"></a>
                                <a href="#" onclick="rename()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz08.gif")"></a>
                                }
                            }
                            else
                            { 
                             
                                <!--上传按钮 id="spanButtonPlaceholder"-->
                                <span class="icon_btn1" style="display:none;">
                                    <span id="spanButtonPlaceholder"></span>
                                </span>
                                <a href="#" onclick="download()" class="icon_btn1"><img src="@Url.Content("~/Content/images/Dqypt/scxz05.gif")"></a>
                            }
                        }

                        }
                </div>
                <div id="divFileProgressContainer" style="height:75px;display:none;"></div>
                <div class="scxz_list">
                <table width="100%" border="0">
                    <tr>
                        <th width="5%" class="b_r"><input type="checkbox" name="checkbox" id="chkALL" /></th>
                        <th  align="left" class="p_l b_r">文件名</th>
                       
                         @if ((bool)ViewData["isall"])
                         {
                             <th width="9%" class="b_r">部门</th>
                         }
                        <th width="11%" class="b_r">上传人</th>
                         <th width="10%" class="b_r">大小</th>
                        <th width="10%" class="b_r">日期</th>
                    </tr>
                    @foreach (ElingOA6_Admin_DSJCJ.Model.FTP_New ftpModel in Model as List<ElingOA6_Admin_DSJCJ.Model.FTP_New>)
                    {
                        string fId = "chk_" + ftpModel.FID;
                        <tr>
                            <td align="center" class="b_r"><input type="checkbox" name="checkbox2" id="@fId" /></td>
                            <td class="p_l b_r"><div title="@ftpModel.FName" style="width:473px; white-space:nowrap; text-overflow:ellipsis; -o-text-overflow:ellipsis; overflow: hidden; line-height: 38px; font-size: 12px;">
                             @if (ftpModel.FType == "D")
                             {
                                 <img alt="" src="@Url.Content("~/Content/ControlImages/button_folder.gif")" />
                             }
                            @ftpModel.FName</div></td>
                             @if ((bool)ViewData["isall"])
                             { 
                                   if (ftpModel.FType == "D")
                                   {
                                       <td align="center" class="b_r"></td>
                                   }
                                     if (ftpModel.FType == "F")
                                     { 
                               <td align="center" class="b_r" style="white-space:nowrap; text-overflow:ellipsis; -o-text-overflow:ellipsis; overflow: hidden;">@ftpModel.FDeptName</td>
                                     }
                             }
                             @if (ftpModel.FType == "F")
                             { 
                            <td align="center" class="b_r">@ftpModel.FUserName</td>
                             <td align="center" class="b_r">@ftpModel.strSize</td>
                            <td align="center" class="b_r">@ftpModel.FDate.ToString("yyyy-MM-dd ")</td>
                             }
                             else
                             {
                                 <td align="center" class="b_r"></td>
                             <td align="center" class="b_r"></td>
                            <td align="center" class="b_r"></td>
                             }
                             
                        </tr>
                    }
                </table>
                <table width="100%" cellspacing="0" cellpadding="0" height="35">
                    <tr>
                        <td style=" padding:0 20px;">
                            <span style="float: left; display:block;">共 @Model.TotalItemCount 条记录，页 @Model.CurrentPageIndex/@Model.TotalPageCount</span>
                            <span style="float:right; display:block;">
                            @Html.Pager(Model, new PagerOptions { ContainerTagName = "span", PageIndexParameterName = "id", AlwaysShowFirstLastPageNumber = true, HorizontalAlign = "right", FirstPageText = "首页", LastPageText = "末页" }, new { style = "" })
                            </span>
                        </td>
                    </tr>
                </table>
                </div>
            </div>
        </td>
    </tr>
</table>



<div id="hiddiv" name="hiddiv" style="display: none; visibility: hidden">
  <iframe id='popContent' name='popContent' style='width: 0px; height: 0px; display: none; visibility: hidden;' frameborder='0'
                        src='' scrolling="no"></iframe>
</div>

@Html.Hidden("hdParentId", ViewData["parentId"])
@Html.Hidden("hdSelEnterpriseFTPKeys")

</body>
</html>
